/*!
Copyright (C) 2014, 申瑞珉 (Ruimin Shen)

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

#pragma once

#include <cassert>
#include <vector>
#include <set>
#include <boost/numeric/ublas/symmetric.hpp>

namespace otl
{
namespace problem
{
namespace community_discovery
{
template <typename _TIterator>
bool CheckCommunities(const size_t size, _TIterator begin, _TIterator end)
{
	std::set<size_t> merge;
	for (_TIterator i = begin; i != end; ++i)
	{
		const std::set<size_t> &community = *i;
		for (auto j = community.begin(); j != community.end(); ++j)
		{
			if (merge.find(*j) != merge.end())
				return false;
			merge.insert(*j);
		}
	}
	return merge.size() == size;
}
}
}
}
